package org.nbict.iot.trident.mogo.mapper.impl;

import org.apache.storm.mongodb.common.QueryFilterCreator;
import org.apache.storm.tuple.ITuple;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.nbict.iot.trident.mogo.mapper.MongoMapper;

/**
 *
 * 简单插入
 * Created by songseven on 18/6/25.
 */
public class SimpleMongoMapper implements MongoMapper {

    private String[] fields;

    public SimpleMongoMapper() {
    }

    public Document toDocument(ITuple tuple) {
        Document document = new Document();
        String[] var3 = this.fields;
        int var4 = var3.length;

        for(int var5 = 0; var5 < var4; ++var5) {
            String field = var3[var5];
            document.append(field, tuple.getValueByField(field));
        }

        return document;
    }

    @Override
    public Bson filter(ITuple tuple) {
        return null;
    }

    public SimpleMongoMapper withFields(String... fields) {
        this.fields = fields;
        return this;
    }

    public SimpleMongoMapper withFilter(QueryFilterCreator filterCreator) {
        return this;
    }
}
